package com.xzr.hospitalregister.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xzr.hospitalregister.R;
import com.xzr.hospitalregister.entity.DthzYSListItem;

import java.util.List;

/**
 * Created by Administrator on 2018/1/26 0026.
 */

public class DthzYSItemAdapter extends RecyclerView.Adapter<DthzYSItemAdapter.MyHolder>{
    private List<DthzYSListItem> data2;
    private Context context;
    public DthzYSItemAdapter(List<DthzYSListItem> data2, Context context){
        this.data2 = data2;
        this.context = context;
    }
    private OnClickListener onClickListener;
    public void setOnClickListener(OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    public interface OnClickListener {
        void onLongClickListener(int position);
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyHolder(LayoutInflater.from(context).inflate(R.layout.item_recycler_dthzys, null));
    }

    @Override
    public void onBindViewHolder(MyHolder holder, final int position) {
        holder.edittext_yisheng.setText(data2.get(position).getYsName());
        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                onClickListener.onLongClickListener(position);
                return true;
            }
        });
    }

    @Override
    public int getItemCount() {
        return data2.size();
    }
    class MyHolder extends RecyclerView.ViewHolder{
        TextView edittext_yisheng;
        public MyHolder(View itemView) {
            super(itemView);
            edittext_yisheng = (TextView) itemView.findViewById(R.id.edittext_yisheng);
        }
    }
}
